package com.qf.login.service.impl;

import com.qf.login.service.TokenService;
import com.qf.utils.TokenUtils;
import org.springframework.stereotype.Service;

@Service
public class JwtTokenServiceImpl implements TokenService {

    @Override
    public String createToken(String username, Integer time) {
        return TokenUtils.createToken(username,time);
    }

    @Override
    public boolean checkToken(String token) {

        try {
            boolean b = TokenUtils.checkToken(token);
            return b;
        } catch (Exception e) {
            // 如果上面的checkToken方法抛出异常，那么等同于token校验错误
           return false;
        }

    }
}
